package com.wangzhy.financial.controller;

import java.util.List;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.wangzhy.financial.domain.XmConfig;
import com.wangzhy.financial.service.IXmConfigService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 项目配置信息Controller
 *
 * @author wangzhy
 * @date 2021-11-15
 */
@RestController
@RequestMapping("/financial/xmConfig")
@Api(tags = "项目配置信息")
public class XmConfigController extends BaseController
{
    @Autowired
    private IXmConfigService xmConfigService;

    /**
     * 查询项目配置信息列表
     */
    @ApiOperation("查询项目配置信息列表")
    @PreAuthorize("@ss.hasPermi('financial:xmConfig:list')")
    @GetMapping("/list")
    public TableDataInfo list(XmConfig xmConfig)
    {
        startPage();
        List<XmConfig> list = xmConfigService.selectXmConfigList(xmConfig);
        return getDataTable(list);
    }

    /**
     * 导出项目配置信息列表
     */
    @ApiOperation("导出项目配置信息列表")
    @PreAuthorize("@ss.hasPermi('financial:xmConfig:export')")
    @Log(title = "项目配置信息", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(XmConfig xmConfig)
    {
        List<XmConfig> list = xmConfigService.selectXmConfigList(xmConfig);
        ExcelUtil<XmConfig> util = new ExcelUtil<XmConfig>(XmConfig.class);
        return util.exportExcel(list, "xmConfig");
    }

    /**
     * 获取项目配置信息详细信息
     */
    @ApiOperation("获取项目配置信息详细信息")
    @PreAuthorize("@ss.hasPermi('financial:xmConfig:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(xmConfigService.selectXmConfigById(id));
    }

    /**
     * 新增项目配置信息
     */
    @ApiOperation("新增项目配置信息")
    @PreAuthorize("@ss.hasPermi('financial:xmConfig:add')")
    @Log(title = "项目配置信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody XmConfig xmConfig)
    {
        return toAjax(xmConfigService.insertXmConfig(xmConfig));
    }

    /**
     * 修改项目配置信息
     */
    @ApiOperation("修改项目配置信息")
    @PreAuthorize("@ss.hasPermi('financial:xmConfig:edit')")
    @Log(title = "项目配置信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody XmConfig xmConfig)
    {
        return toAjax(xmConfigService.updateXmConfig(xmConfig));
    }

    /**
     * 删除项目配置信息
     */
    @ApiOperation("删除项目配置信息")
    @PreAuthorize("@ss.hasPermi('financial:xmConfig:remove')")
    @Log(title = "项目配置信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(xmConfigService.deleteXmConfigByIds(ids));
    }
}
